package com.whut.controller;

import com.whut.common.Result;
import com.whut.service.SysPermissionService;
import com.whut.vo.SysPermissionMenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;


/**
 * 视图转化的时候使用的controller层
 *
 * @author
 * @create 2021-04-05 23:03
 */

@Controller
@RequestMapping("page")
public class PageController {

    @Autowired
    private SysPermissionService sysPermissionService;

    /**
     * 转到主页面去，然后开始之后的操作
     *
     * @return
     */
    @RequestMapping("main.do")
    public ModelAndView main() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("main");
        Result leftMenu = sysPermissionService.getLeftMenu();
        List<SysPermissionMenuVo> data = (List<SysPermissionMenuVo>) leftMenu.getData();
        SysPermissionMenuVo sysPermissionMenuVo = data.get(0).getChildren().get(0);
        String href = sysPermissionMenuVo.getHref();
        modelAndView.addObject("href",href);
        return modelAndView;
    }

    /**
     * 转化到userlist中的这个jsp页面，然后来写的。
     *
     * @return
     */
    @RequestMapping("user/list.do")
    public String userList() {
        return "user/list";
    }


    /**
     * 角色列表，然后在这个地方进行设置，这个就是觉得表的设置
     *
     * @return
     */
    @RequestMapping("role/list.do")
    public String roleList() {
        return "role/list";
    }

    @RequestMapping("perm/list.do")
    public String permList() {
        return "perm/list";
    }
}
